package com.example.demo.controller;

import com.example.demo.service.AsyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AsyncController
 * @Author bsy
 * @Description TODO
 * @Date 2022/8/9 23:36
 * @Version 1.0
 */
@RestController
public class AsyncController {
    @Autowired
    AsyncService asyncService;

    @GetMapping("/async/hello")
    public String hello(){
        long time1 = System.currentTimeMillis();
        asyncService.hello();//调用异步方法
        long time2 = System.currentTimeMillis();
        System.out.println("Controller  :"+(time2-time1));
        return "success";
    }
}
